package org.come.Frame;

import com.tool.image.ImageMixDeal;
import com.tool.tcpimg.UIUtils;

import org.come.Jpanel.QiandaoListJpanel;
import org.come.until.FormsManagement;
import org.come.until.MessagrFlagUntil;
import org.come.until.Music;
import org.come.until.Util;

import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.*;
import javax.swing.plaf.basic.BasicInternalFrameUI;

public class QiandaoListJframe extends JInternalFrame implements MouseListener{

	private static QiandaoListJpanel qiandaoListJpanel;
	private int first_x,first_y;//x、y坐标

	public static QiandaoListJframe getRankingListJframe() {
		return (QiandaoListJframe) FormsManagement.getInternalForm(60).getFrame();
	}

	public QiandaoListJframe() {
		qiandaoListJpanel = new QiandaoListJpanel();
		this.getContentPane().add((Component) qiandaoListJpanel);
		this.setBorder(BorderFactory.createEmptyBorder());
		((BasicInternalFrameUI)this.getUI()).setNorthPane(null);
		this.setBounds(140, 140, 700, 500);
		this.setOpaque(false);
		this.pack();
		this.setDefaultCloseOperation(3);
		this.setVisible(false);
		this.addMouseListener((MouseListener)this);
		this.addMouseMotionListener(new MouseMotionListener() {
			@Override
			public void mouseMoved(final MouseEvent e) {
				if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE13)) {
					MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
				}
			}

			@Override
			public void mouseDragged(final MouseEvent e) {
				if (QiandaoListJframe.this.isVisible()) {
					final int x = e.getX() - QiandaoListJframe.this.first_x;
					final int y = e.getY() - QiandaoListJframe.this.first_y;
					QiandaoListJframe.this.setBounds(x + QiandaoListJframe.this.getX(), y + QiandaoListJframe.this.getY(), QiandaoListJframe.this.getWidth(), QiandaoListJframe.this.getHeight());
				}
			}
		});
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		FormsManagement.showForm(1100);
		//关闭按钮
		//开启窗口音效
		 Music.addyinxiao("关闭窗口.mp3");
		//打开了窗体
		if(e.isMetaDown()){//检测鼠标右键单击
			FormsManagement.HideForm(1100);
		}else {
			FormsManagement.Switchinglevel(1100);
		}
		this.first_x = e.getX();
		this.first_y = e.getY();
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	public static QiandaoListJpanel getQiandaoListJpanel() {
		return qiandaoListJpanel;
	}

	public void setQiandaoListJpanel(QiandaoListJpanel qiandaoListJpanel) {
		QiandaoListJframe.qiandaoListJpanel = qiandaoListJpanel;
	}

	public int getFirst_x() {
		return first_x;
	}

	public void setFirst_x(int first_x) {
		this.first_x = first_x;
	}

	public int getFirst_y() {
		return first_y;
	}

	public void setFirst_y(int first_y) {
		this.first_y = first_y;
	}
}
